class Human:
    def __init__(self, name, weight):
        self.name = name
        self.weight_cv = weight

    def __str__(self):
        return f'我们说的这个男孩叫作{self.name}，他的体重是{self.weight_cv}公斤。'

    def run(self):
        self.weight_cv -= 6
        return f'{self.name}觉得不能这么重下去了，遂坚持跑步，现在体重是{self.weight_cv}公斤。'

    def eat(self):
        self.weight_cv += 6
        return f'好景不长，过年的那段时间{self.name}怠惰了，暴饮暴食之后，他的体重回到了{self.weight_cv}公斤。'


boy = Human('小明', 75)
print(boy)
print(boy.run())
print(boy.eat())
print(boy)


class Houses:
    def __init__(self, name, total_area, free_area=None, item_list=None):
        self.nm = name
        self.ta = total_area
        if free_area is None:
            self.fa = free_area = self.ta = total_area
        self.fa = free_area
        if item_list is None:
            item_list = []
        # else:
        #     for x in item_list:
        #         self.fa -= x.oa
        self.il = item_list

    def __str__(self):
        return f'这栋房子的户型是{self.nm}，总面积是{self.ta}平米，剩余面积是{self.fa}平米，家具名称列表是{self.il}。'

    def add_item(self, item_name):
        if self.fa >= item_name.oa:
            self.il.append(item_name.nm)
            self.fa -= item_name.oa
            print(self)
        else:
            print(f'户型为{self.nm}的房子剩余空间不足，仅剩{self.fa}平米，然而现在还想塞入占地{item_name.oa}平米的家具，办不到！')


class HouseItem:
    def __init__(self, name, occ_area):
        self.nm = name
        self.oa = occ_area

    def __str__(self):
        return f'{self.nm}占地{self.oa}平米'


bed = HouseItem('bed', 4)
chest = HouseItem('chest', 2)
table = HouseItem('table', 1.5)
desk = HouseItem('desk', 2)
TV = HouseItem('Television', 0.8)
sofa = HouseItem('sofa', 1.6)
print(bed)
print(chest)
print(table)
print(desk)
print(TV)
print(sofa)
my_house = Houses('A', 150, 100, [desk.nm, TV.nm])
your_house = Houses('C', 10, 2.8)
print(my_house)
print(your_house)
my_house.add_item(bed)
my_house.add_item(chest)
my_house.add_item(table)
your_house.add_item(desk)
your_house.add_item(TV)


class LoginPage:
    def __init__(self, username, password, code, button=1):
        self.usnm = username
        self.pwd = password
        self.vrcd = code
        self.lgbt = button

    def login(self):
        if self.usnm == 'admin' and self.pwd == '123456' and self.vrcd == '8888' and self.lgbt == 1:
            print(f'登录成功！{self.usnm}，欢迎您！')
        else:
            print('登录失败！')


a = input('请输入用户名：')
b = input('请输入密码：')
c = input('请输入验证码：')
login_user = LoginPage(a, b, c)
login_user.login()
